package com.ifd.iview.common;

import java.io.InputStream;
import java.util.Properties;

import javax.servlet.ServletConfig;

import org.apache.log4j.PropertyConfigurator;

public class IviewAppConfig {
	private static IviewAppConfig instance = null;

	public static void init(ServletConfig config) throws Exception{
		instance = new IviewAppConfig(config);
	}

	public static IviewAppConfig getInstance() {
		return instance;
	}
	
	private Properties configs;
	public IviewAppConfig(ServletConfig config) throws Exception{
		InputStream is = config.getServletContext().getResourceAsStream("/WEB-INF/config/iview-app.ini");
		configs = new Properties();
		configs.load(is);
		PropertyConfigurator.configure(config.getServletContext().getResourceAsStream("/WEB-INF/config/log4j.ini"));
	}
	public String getProperty(String key){
		return configs.getProperty(key);
	}
}
